package com.artist.controller;

import com.artist.entity.TbList;
import com.artist.service.ListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "二级导航")
@RestController
public class ListController {
    @Autowired
    private ListService listService;

    @ApiOperation(value = "二级导航列表")
    @GetMapping("/tblist")
    public List<TbList> getAllList() {
        return listService.allList();
    }

    @ApiOperation(value = "单个二级导航")
    @GetMapping("/tblist/{listId}")
    public TbList getListById(@PathVariable Long listId) {
        return listService.selectByPrimaryKey(listId);
    }

    @ApiOperation(value = "新增二级导航")
    @PostMapping("/tblist")
    public void insertTbList(@RequestBody TbList tbList){
        listService.saveList(tbList);
    }

    @ApiOperation(value = "编辑二级导航")
    @PutMapping("/tblist/{listId}")
    public void updateTbList(@RequestBody TbList tbList){
        listService.updateList(tbList);
    }
    @ApiOperation(value = "删除二级导航")
    @DeleteMapping("/tblist/{listId}")
    public void deleteTblistById(@PathVariable Long listId){
        listService.deleteList(listId);
    }
}
